import React, { Component } from 'react';
import { Input } from 'antd';
import Label from '../LabelDecorator';
import Validator from '../ValidatorDecorator';

@Validator()
@Label()
class TextInput extends Component {
  render() {
    const { getData, validator, labelWidth=0 } = this.props;
    const input = (
      <Input
        onChange={event => {
          validator(event.target.value);
        }}
        style={{ width: 'calc(100% - ' + labelWidth + 'px)', height: '100%' }}
        placeholder={getData('placeholder')}
      />
    );
    return input;
  }
}

export default TextInput;
